<template>
	<view>
		<view class="context">

			<view class="products">
				<view class="item" v-for="item in list" @click="toDetail(item.id)">
					<image :src="item.img" mode="widthFix"></image>
					<view class="context">
						<text class="product-name">{{item.title}}</text>
						<text class="summary"> {{item.summary.length < 60 ? item.summary : item.summary.substr(0,59)+'...'}}</text>
<!-- 						<view class="like">
							<uni-icons type="heart" size="18" color="#ff8785"></uni-icons>
							<text>{{item.like}}</text>
						</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			};
		},
		methods: {
			init() {
				this.get('product/getBySort', null, (res) => {
					this.list = res.data.list
				})
			},
			toDetail(id){
				uni.navigateTo({
					url: '../detail/detail?id=' + id,
					animationType: 'slide-in-right'
				})
			}
		},
		onLoad() {
			this.init()
		}
	}
</script>

<style lang="scss">
	.context {
		margin: 30rpx;
		.products {
			padding: 20rpx 10rpx;
			padding-bottom: 40rpx;
			display: flex;
			flex-direction: column;

			.item {
				margin-bottom: 40rpx;
				display: flex;
				align-content: center;
				justify-content: space-between;
				flex-direction: row;

				image {
					margin-right: 20rpx;
					flex-shrink: 0;
					height: 200rpx;
					width: 200rpx;
				}

				.context {
					display: flex;
					flex-direction: column;

					.product-name {
						font-size: $uni-font-size-base;
						font-weight: 600;
					}

					.summary {
						padding: 20rpx 0;
						font-size: $uni-font-size-sm;
						color: $uni-text-color-placeholder
					}

					.like {
						color: $color2;
						display: flex;
						flex-direction: row;
						justify-content: center;
						align-items: center;
						font-size: $uni-font-size-sm;
						align-self: flex-end;

						text {
							padding-left: 10rpx;
						}
					}
				}
			}
		}
	}
</style>
